#include<iostream>

class Car//被装饰的基类抽象类
{
public:
    Car()=default;
    Car(const std::string&name):name(name){}
    virtual void showInfo()=0;
protected:
    std::string name;

};
class BMW:public Car//被装饰的具体类
{
public:
    using Car::Car;
    void showInfo()
    {
        std::cout<<name<<std::endl;
    }


};
class Decorate:public Car//抽象装饰类
{
public:
    using Car::Car;
    void decorate(Car *c)
    {
        this->=c;
    }
     

};
protected:
    Car *c;//要装饰的对象

class SelfDrive:public Decorate
{

public:
    void showInfo()
    {
        std::cout<<"自动驾驶"
        c->showInfo();
    }
};
class VoiceControl:public Decorate
{

public:
    void showInfo()
    {
        std::cout<<"导航"
        c->showInfo();
    }
};




int main()
{
    Car *C=new BMW("宝马");
    C->showInfo();

    Decorate *d1=new SelfDrive;   
    Decorate *d2=new VoiceControl;
    d1->decorate(c);//装饰
    d2->decorate(d1);
    d2->showInfo();

    return 0;
}
